#include "stdafx.h"
#include "ShaderManager.h"

GLint ShaderManager::loc_mylight_position = 0;
GLint ShaderManager::loc_mylight_color = 0;
GLint ShaderManager::loc_mylight_direction = 0;
GLint ShaderManager::loc_mylight_type = 0;
GLint ShaderManager::loc_render_type = 0;
GLint ShaderManager::loc_tangent = 0;
GLint ShaderManager::loc_difuse_map = 0;
GLint ShaderManager::loc_normal_map = 0;	
GLint ShaderManager::loc_cube_map = 0; 


Shaders* ShaderManager::lightShaders = new Shaders();
Shaders* ShaderManager::normalShaders = new Shaders();
Shaders* ShaderManager::silhouetteShaders = new Shaders();
Shaders* ShaderManager::goochShaders = new Shaders();
Shaders* ShaderManager::textureShaders = new Shaders();

ShaderManager::ShaderManager(void){ }

ShaderManager::~ShaderManager(void){ }

void ShaderManager::init(void)
{
	lightShaders->init("shaders/light.vert.glsl","shaders/light.frag.glsl");
	normalShaders->init("shaders/normal.vert.glsl","shaders/normal.frag.glsl");
	silhouetteShaders->init("shaders/silhouette.vert.glsl","shaders/silhouette.frag.glsl");
	goochShaders->init("shaders/gooch.vert.glsl","shaders/gooch.frag.glsl");
	textureShaders->init("shaders/texture.vert.glsl","shaders/texture.frag.glsl");

	loc_mylight_position = lightShaders->getUniformLocation("mylight_position");
	loc_mylight_color = lightShaders->getUniformLocation("mylight_color");
	loc_mylight_direction = lightShaders->getUniformLocation("mylight_direction");
	loc_mylight_type = lightShaders->getUniformLocation("mylight_type");
	loc_render_type = lightShaders->getUniformLocation("render_type");
	loc_tangent = lightShaders->getUniformLocation("tangent");
	loc_difuse_map = lightShaders->getUniformLocation("colorTexture");
	loc_normal_map = lightShaders->getUniformLocation("normalTexture");
	loc_cube_map = lightShaders->getUniformLocation("cubeTexture");
}

void ShaderManager::changeShader(int shader)
{
	switch (shader)
	{
		case light_Shaders:
			glUseProgram(lightShaders->shaderprogram);
			break;
		case normal_Shaders:
			glUseProgram(normalShaders->shaderprogram);
			break;
		case silhouette_Shaders:
			glUseProgram(silhouetteShaders->shaderprogram);
			break;
		case gooch_Shaders:
			glUseProgram(goochShaders->shaderprogram);
			break;
		case texture_Shaders:
			glUseProgram(textureShaders->shaderprogram);
			break;
		default:
			break;
	}
}